from rest_framework import serializers

from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory


class ChannelsSerializer(serializers.ModelSerializer):
    # 1,重写spec
    # spec = serializers.StringRelatedField(read_only=True)
    # spec_id = serializers.IntegerField()

    # 重写频道组ID
    group = serializers.StringRelatedField(read_only=True)
    group_id =serializers.IntegerField()

    #重写一级分类ID
    category = serializers.StringRelatedField(read_only=True)
    category_id = serializers.IntegerField()

    class Meta:
        model = GoodsChannel
        fields = "__all__"


class ChannelsGroupSerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsChannelGroup
        fields = "__all__"

class CategoriesSerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields = "__all__"